faceBook = function($)
{
  var userData = {}, init = function()
  {
    FB.init({
      appId : '397916723571557',
      channelUrl : '//foxtrotbravodehack3.appspot.com/channel.html',
      status : true,
      cookie : true,
      xfbml : true
    });
    fetchUserData();
  }, fetchUserData = function()
  {
    if (FB._authResponse)
    {
      FB.api('/me', function(response)
      {
        userData = response;
        for ( var i in userData)
        {
          $("body").append("<div><B>" + i + "</B>: " + userData[i] + "</div>");
        }
      });
    }
    else
    {
      setTimeout(function()
      {
        fetchUserData();
      }, 100);
    }
  }, getUser = function()
  {
    return userData;
  };

  return {
    init : init,
    getUser : getUser
  };
}(jQuery);

$(function()
{
  faceBook.init();
});